<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('朗讼达人列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>用户ID：</p>
                                <input type="text" name="kkuid"/>
                            </li>
                            <li>
                                <p>当前等级：</p>
                                <select name="level" th:with="type=${@dict.getType('audio_topman_level')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <p>达到等级：</p>
                                <select name="scoreLevel" th:with="type=${@dict.getType('audio_topman_level')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">

            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('yuwen:topman:edit')}]];
        var removeFlag = [[${@permission.hasPermi('yuwen:topman:remove')}]];
        var levelDatas = [[${@dict.getType('audio_topman_level')}]];
        var scoreLevelDatas = [[${@dict.getType('audio_topman_level')}]];
        var prefix = ctx + "yuwen/topman";
        var audioListPrefix = ctx + "yuwen/yuwenaudio/userList"

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "朗讼达人",
                columns: [{
                    checkbox: true
                },
                {
                    field : 'id', 
                    title : 'ID',
                    visible: false
                },
                {
                    field : 'kkuid', 
                    title : '用户ID'
                },
                {
                    field : 'nickname',
                    title : '用户昵称'
                },
                {
                    field : 'level', 
                    title : '当前等级',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(levelDatas, value);
                    }
                },
                {
                    field : 'scoreLevel', 
                    title : '达到等级',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(scoreLevelDatas, value);
                    }
                },
                {
                    field : 'totalAudio', 
                    title : '朗讼总数'
                },
                {
                    field : 'totalPraise',
                    title : '点赞总数'
                },
                {
                    field : 'totalPlay',
                    title : '播放总数'
                },
                {
                    field : 'activePraise',
                    title : '活动点赞数'
                },
                {
                    field : 'level1Audio', 
                    title : '朗讼数(点赞数>10)'
                },
                {
                    field : 'level2Audio', 
                    title : '朗讼数(点赞数>20)'
                },
                {
                    field : 'level3Audio', 
                    title : '朗讼数(点赞数>30)'
                },
                {
                    field : 'level4Audio', 
                    title : '朗讼数(点赞数>40)'
                },
                {
                    field : 'level5Audio', 
                    title : '朗讼数(点赞数>50)'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="audioList(\'' + row.kkuid + '\',\'' + row.nickname + '\')"><i class="fa fa-edit"></i>作品列表</a> ');
                        if(row.scoreLevel > row.level)
                        {
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="approveUpLevel(\'' + row.id + '\')"><i class="fa fa-edit"></i>提交升级</a> ');
                        }
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>手动调级</a> ');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function approveUpLevel(id){
           $.modal.confirm("确定要提交升级吗?", function() {
				$.operate.post(prefix + "/approveUpLevel", { "id": id});
		   })
		}

	    function audioList(kkuid, nickname) {
		    var url = audioListPrefix + "/" + kkuid;
		    $.modal.openTab(nickname + "朗讼作品列表", url);
		}


    </script>
</body>
</html>